﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GeekShop
{
    public partial class ColorDialog : Form
    {
        #region Fields
        private Color color;
        #endregion

        #region Static Fields
        private static ColorDialog form = null;
        private static Color defaultColor = Color.Black;
        #endregion

        #region Properties
        public Color Color
        {
            get { return this.color; }
            set { this.color = value; }
        }
        #endregion

        #region Static Properties
        public static ColorDialog Form
        {
            get
            {
                return ColorDialog.form;
            }
            set
            {
                if (ColorDialog.form == null)
                {
                    ColorDialog.form = value;
                }
            }
        }
        #endregion

        #region Constructors
        public ColorDialog(Color color)
        {
            this.color = color;
        }
        public ColorDialog(): this(ColorDialog.defaultColor) { }
        #endregion

        #region Public Methods
        public void Reset()
        {
            this.color = ColorDialog.defaultColor;
        }
        public DialogResult RunDialog()
        {
            System.Windows.Forms.ColorDialog dialog = new System.Windows.Forms.ColorDialog();
            dialog.Color = this.color;
            DialogResult result = dialog.ShowDialog();
            this.color = dialog.Color;
            return result;
        }
        #endregion
    }
}
